package _220_Contains_Duplicate_III;

/**
 * Created by 孙加辉 on 2018/7/22.
 */
class Solution {
    public boolean containsNearbyAlmostDuplicate(int[] nums, int k, int t) {
        for(int i=0;i<nums.length-1;i++){
            for(int j=i+1;j<nums.length&&j<=i+k;j++){
                if(Math.abs((long)nums[i]-(long)nums[j])<=t)
                    return true;
            }
        }
        return false;
    }
}
public class _220_Contains_Duplicate_III {
    public static void main(String[] args){
       int[] nums = {1,2,3,1};
       int k = 3, t = 0;
       Solution solution = new Solution();
       System.out.println(solution.containsNearbyAlmostDuplicate(nums,k,t));
    }
}
